#include "glare.core.DriverCapabilities.h"

namespace Glare {

	DriverCapabilities::DriverCapabilities() 
		: _primitive_type_map(NULL)
		, _shader_var_update_caps(ShaderVariableUpdate::None)
	{
		_primitive_type_map = new bool[GpuPrimitive::Max];
		memset(_primitive_type_map, false, sizeof(bool) * GpuPrimitive::Max);
	}

	DriverCapabilities::~DriverCapabilities()
	{
		delete[] _primitive_type_map;
		_primitive_type_map = NULL;
	}

	void DriverCapabilities::SetSupportedPrimitivesAll()
	{
		memset(_primitive_type_map, true, sizeof(bool) * GpuPrimitive::Max);
	}

	void DriverCapabilities::SetSupportedPrimitives(const std::list<GpuPrimitive::Type> supported_primitives)
	{
		std::list<GpuPrimitive::Type>::const_iterator it = supported_primitives.begin();
		std::list<GpuPrimitive::Type>::const_iterator end = supported_primitives.end();

		while (it != end)
		{
			GpuPrimitive::Type type = *it;
			_primitive_type_map[type] = true;
			++it;
		}
	}

	const bool& DriverCapabilities::IsPrimitiveSupported(const GpuPrimitive::Type& primitive_type) const
	{
		return _primitive_type_map[primitive_type];
	}

	void DriverCapabilities::SetShaderVariableUpdateCapabilities(const ShaderVariableUpdate::Capabilities& capabilities)
	{
		_shader_var_update_caps = capabilities;
	}

	const ShaderVariableUpdate::Capabilities& DriverCapabilities::GetShaderVariableUpdateCapabilities() const
	{
		return _shader_var_update_caps;
	}
}
